-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generates and labels VolumeGroupSnapshotClass
#168
base: main
Are you sure you want to change the base?
Conversation
d68c5d2
to
7e993b3
Compare
38c58d7
to
b148266
Compare
VolumeGroupSnapshotClass
Volume*SnapshotClass
Volume*SnapshotClass
Volume*SnapshotClass
/cc @rewantsoni |
Volume*SnapshotClass
Volume*SnapshotClass
Volume*SnapshotClass
Volume*SnapshotClass
63d1586
to
0af9ddc
Compare
labels["ramendr.openshift.io/replicationID"] = r.storageClaimHash | ||
labels["ramendr.openshift.io/storageID"] = storageID | ||
if resource.Name == "cephfs" { | ||
volumeSnapshotClass = r.getCephFSVolumeSnapshotClass(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The labels are not being applied to the cephfs or rbd VolumeSnapshotClass
labels["ramendr.openshift.io/replicationID"] = r.storageClaimHash | |
labels["ramendr.openshift.io/storageID"] = storageID | |
if resource.Name == "cephfs" { | |
volumeSnapshotClass = r.getCephFSVolumeSnapshotClass(data) | |
labels["ramendr.openshift.io/replicationID"] = r.storageClaimHash | |
labels["ramendr.openshift.io/storageID"] = storageID | |
if resource.Name == "cephfs" { | |
volumeSnapshotClass = r.getCephFSVolumeSnapshotClass(data,labels) |
if reflect.DeepEqual(existing.Parameters, volumeGroupSnapshotClass.Parameters) { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check for labels?
ad64a3a
to
15d83d2
Compare
pkg/utils/k8sutils.go
Outdated
return err | ||
} | ||
|
||
obj.SetResourceVersion("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment reg why this is required?
something like:
k8s doesn't allow us to create objects when resourceVersion is set, as we are DeepCopying the object, the resource version also gets copied, hence we need to set it to empty before creating it
} else if resource.Name == "ceph-rbd" { | ||
volumeSnapshotClass = r.getCephRBDVolumeSnapshotClass(data) | ||
} | ||
volumeSnapshotClass = r.getCephDriverVolumeSnapshotClass(resource.Labels, resource.Annotations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also set the Labels and annotation in CreateOrReplace for all resources
89f459e
to
8865ae0
Compare
@raaizik can we split this in to Two PR's one for volumesnapshotclass and another one for volumegroupsnapshotclass? we can get the volumesnapshotclass PR merged and we can visit the volumegroupsnapshotclass PR once we have the feature in betav1 state. |
Volume*SnapshotClass
VolumeSnapshotClass
VolumeSnapshotClass
VolumeGroupSnapshotClass
6356b95
to
27dc75c
Compare
d1858ea
to
5af8ff3
Compare
@@ -141,6 +184,17 @@ func (r *StorageClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request | |||
r.ctx = ctrllog.IntoContext(ctx, r.log) | |||
r.log.Info("Reconciling StorageClaim.") | |||
|
|||
crd := &metav1.PartialObjectMetadata{} | |||
for _, crdName := range []string{volumeGroupSnapshotClassCrd, drClusterConfigCRDName} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have drClusterConfigCRDName
isnt this PR only for VGSC?
return nil | ||
}) | ||
if err != nil { | ||
return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed to create or update StorageClass
to failed to create or update VolumeGroupSnapshotClass
Labels: labels, | ||
Annotations: annotations, | ||
}, | ||
Driver: templates.RBDDriverName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be configurable as we need to support for both cephfs and rbd
Signed-off-by: raaizik <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: raaizik The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also test this PR on a cluster to see if the VGSC is created with the required fields
@@ -401,7 +454,35 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) { | |||
return nil | |||
}) | |||
if err != nil { | |||
return reconcile.Result{}, fmt.Errorf("failed to create or update VolumeSnapshotClass: %s", err) | |||
return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err) | |
return reconcile.Result{}, fmt.Errorf("failed to create or update VolumeSnapshotClass: %s", err) |
You are under the VolumeSnapshotClass case here not StorageClass
data := map[string]string{} | ||
err = json.Unmarshal(resource.Data, &data) | ||
if err != nil { | ||
return reconcile.Result{}, fmt.Errorf("failed to unmarshal StorageClaim configuration response: %v", err) | ||
} | ||
data["csi.storage.k8s.io/group-snapshotter-secret-namespace"] = r.OperatorNamespace | ||
// generate a new clusterID for cephfs subvolumegroup, as | ||
// storageclaim is clusterscoped resources using its | ||
// hash as the clusterID | ||
data["clusterID"] = r.storageClaimHash | ||
driverName := templates.CephFsDriverName | ||
if strings.Contains(strings.ToLower(resource.Name), "rbd") { | ||
driverName = templates.RBDDriverName | ||
} | ||
volumeGroupSnapshotClass = r.getCephDriverVolumeGroupSnapshotClass(resource.Labels, resource.Annotations, driverName) | ||
utils.AddAnnotation(volumeGroupSnapshotClass, storageClaimAnnotation, r.storageClaim.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move everything under CreateOrReplace
@@ -550,6 +636,20 @@ func (r *StorageClaimReconciler) getCephRBDVolumeSnapshotClass() *snapapi.Volume | |||
return volumesnapshotclass | |||
} | |||
|
|||
func (r *StorageClaimReconciler) getCephDriverVolumeGroupSnapshotClass( | |||
labels map[string]string, annotations map[string]string, driver string) *groupsnapapi.VolumeGroupSnapshotClass { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add the labels/annotations directly in the CreateOrReplace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might not need this function, we could have everything under CreateOrReplace.
Changes
VolumeGroupSnapshotClass
with the required labels for RDR added to both VGSC and VSC.RHSTOR-5795
TODO
VolumeGroupSnapshotClass
#1150